package ua.dou;

import android.content.Intent;
import android.os.Bundle;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;

/**
 * Created with IntelliJ IDEA.
 * User: sergii
 * Date: 3/31/13
 * Time: 5:39 AM
 * To change this template use File | Settings | File Templates.
 */
public class ShareActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getSupportMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.save_button:
                Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
                sharingIntent.setType("text/plain");
                sharingIntent.putExtra(Intent.EXTRA_SUBJECT, getContentDigest());
                sharingIntent.putExtra(Intent.EXTRA_TEXT, getContentToShare());
                startActivity(sharingIntent);
                break;
            case android.R.id.home:
                finish();
        }
        return super.onOptionsItemSelected(item);
    }

    private String getContentToShare() {
        // TODO SK get content from db or http
        //while stub
        return "sharing content";
    }

    private String getContentDigest() {
        // TODO SK get content from db or http
        //while stub
        return "digest!";
    }

}
